package jsyf.oa.web.attach;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.attach.AttachModuleFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2017/12/13 0013.
 */
@Api(value = "通用接口", description = "通用接口")
@Controller
@RequestMapping("/common")
public class AttachModuleController {

    @Resource
    private AttachModuleFacade attachModuleFacade;

    @RequestMapping(value = "/getAttachesByModuleId.json", method = RequestMethod.POST)
    public void getAttachesByModuleId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData){
        JSONObject objParams = JSON.parseObject(jsonData);
        List<JSONObject> objResult = attachModuleFacade.getAttachesByModuleId(objParams.getString("moduleId"));
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(objResult));
    }
}
